package com.joker.aigc.exception;



import com.joker.aigc.domain.entity.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    //全局异常处理
    @ExceptionHandler(Exception.class)
    public R<String> error(Exception e) {
        log.error("进行了全局处理",e);
        return R.error(201,"执行了全局异常处理");
    }

    //特定异常处理
    @ExceptionHandler(ArithmeticException.class)
    public R<String> error2(ArithmeticException e) {
        log.error("ArithmeticException 错误",e);
        return R.error(203,"ArithmeticException算数异常");
    }

}
